package leetCode.offer58_i;

public class Solution1 implements Solution{


    @Override
    public String reverseWords(String s) {
        s = s.trim();
        String[] arrays = s.split(" ");
        StringBuilder stringBuilder = new StringBuilder();
        for (int i=arrays.length-1;i>=0;i--){
            if(arrays[i].equals("")) continue;
            stringBuilder.append(arrays[i]).append(" ");
        }
        return stringBuilder.toString().trim();
    }

    public static void main(String[] args) {
        System.out.println(new Solution1().reverseWords("a good   example"));
    }

}
